package com.mebs.edi.datalayer.jpa;

import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;

import com.mebs.edi.datalayer.UserDao;
import com.mebs.model.User;

public class JpaUserDao extends JpaGenericDao implements UserDao {

	public User getUser(String userName) {
		EntityManager em = getEntityManager();
		
		TypedQuery<User> query = em
			.createQuery("from User u where u.name = :userName", User.class)
			.setParameter("userName", userName);
		User user = query.getSingleResult();
		
		return user;
	}
	
	public User getById(Long id) {
		EntityManager em = getEntityManager();
		
		User user = em.find(User.class, id);
		return user;
	}

}
